package xidian.vlab.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xidian.vlab.dto.QueryDTO;
import xidian.vlab.dto.ResJsonDTO;
import xidian.vlab.service.VMachineService;
import xidian.vlab.utils.ResUtil;

@RestController
@RequestMapping("/machine")
public class MachineController {
    @Autowired
    private VMachineService machineService;

    @GetMapping("/list")
    public ResJsonDTO getMachines(QueryDTO query){
        if (query == null) return ResUtil.ERROR("未提供参数");
        return machineService.getList(query);
    }
    @GetMapping("/VNC")
    public ResJsonDTO getVNC(QueryDTO query){
        if (query == null) return ResUtil.ERROR("未提供参数");
        return machineService.getVNC(query);
    }
    @PostMapping("/update")
    public ResJsonDTO updateMachine(@RequestBody QueryDTO query){
        if (query == null) return ResUtil.ERROR("未提供参数");
        return machineService.updateMachine(query);
    }
}
